#! @SH@
# @configure_input@
#
# gen-classlist.sh.in -- generates the list of classes to compile
# Taken from GNU Classpath project
# Originally GPLv2, upgraded to AGPLv3 via 'or later' clause.
#
# Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
# Copyright (C) 2007 The University of Sheffield
#
# This file is part of DynamiTE.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Linking this library statically or dynamically with other modules is
# making a combined work based on this library.  Thus, the terms and
# conditions of the GNU General Public License cover the whole
# combination.

echo "Adding java source files from srcdir '@top_srcdir@'."
	@FIND@ @top_srcdir@/src/uk \
       -follow -type f -print | grep '\.java$' > ${top_builddir}/lib/classes.1

# Only include generated files once.
if test ! "${top_builddir}" -ef "@top_srcdir@"; then
  echo "Adding generated files in builddir '${top_builddir}'."
  @FIND@ ${top_builddir}/src -follow -type f -print \
  | grep '\.java$' >> ${top_builddir}/lib/classes.1
fi

for filexp in `cat @top_srcdir@/lib/$1.omit` ; do { grep -v ${filexp} < ${top_builddir}/lib/classes.1 > ${top_builddir}/lib/classes.2 ; mv ${top_builddir}/lib/classes.2 ${top_builddir}/lib/classes.1 ; } ; done

new=
if test -e ${top_builddir}/lib/classes; then
  p=`diff ${top_builddir}/lib/classes ${top_builddir}/lib/classes.1`
  if test "$p" != ""; then
    new="true"
    cp ${top_builddir}/lib/classes.1 ${top_builddir}/lib/classes
  fi
else
  new="true"
  cp ${top_builddir}/lib/classes.1 ${top_builddir}/lib/classes
fi

if test "$new" = "true"; then
  echo "JAVA_SRCS = \\" > ${top_builddir}/lib/java.dep
  for i in `cat ${top_builddir}/lib/classes` ; do
    echo $i "\\" >> ${top_builddir}/lib/java.dep
  done
fi

